package net.aiion.weave.impl.ui.xhtml;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import net.aiion.weave.spi.naming.annotations.Bound;
import net.aiion.weave.spi.naming.annotations.DynamicScoped;
import net.aiion.weave.spi.naming.annotations.Named;


@DynamicScoped
@Named
public class StyleSheet
{
    private Map<String, StyleClass> styleClasses;

    public StyleSheet() {
    }

    @Bound
    public void initializeStyleSheet() {
        styleClasses = new HashMap<>();
    }

    public StyleClass createClass(final String aClassName) {
        if (!styleClasses.containsKey(aClassName)) {
            final StyleClass styleClass = new StyleClass(aClassName);
            styleClasses.put(aClassName, styleClass);
        }
        return styleClasses.get(aClassName);
    }

    public Collection<StyleClass> getClasses() {
        return Collections.unmodifiableCollection(styleClasses.values());
    }
}
